﻿#include<iostream>
#include<string>
#include<list>

class person
{
public:
	person(std::string name, int age, int height, int weight)
	{
		this->m_Name = name;
		this->m_Age = age;
		this->m_Height = height;
		this->m_Weight = weight;
	}

	std::string m_Name;
	int m_Age;
	int m_Height;
	int m_Weight;
};

//void printPerson(const std::list<person>& L)
//{
//	for (std::list<person>::const_iterator it = L.begin(); it != L.end(); ++it)
//	{
//		std::cout << "姓名：" << it->m_Name << "年龄：" << (*it).m_Age
//			<< "身高：" << it->m_Height << "体重：" << it->m_Weight << '\n';
//	}
//	std::cout << '\n';
//}

bool mySort(person& p1, person& p2)
{
	if (p1.m_Age == p2.m_Age)
	{
		return p1.m_Height < p2.m_Height;
	}
	else if(p1.m_Age == p2.m_Age && p1.m_Height == p2.m_Height)
	{
		return p1.m_Weight > p2.m_Weight;
	}
	else
	{
		return p1.m_Age < p2.m_Age;
	}

}
void test01()
{
	std::list<person> L1;

	person p1("张三", 16, 170, 100);
	person p2("李四", 12, 175, 105);
	person p3("王五", 18, 160, 100);
	person p4("赵六", 11, 170, 110);
	person p5("狗剩", 20, 160, 115);
	person p6("黄7", 10, 180, 120);
	person p7("黄8", 10, 170, 110);
	person p8("黄9", 10, 170, 160);

	L1.push_back(p1);
	L1.push_back(p2);
	L1.push_back(p3);
	L1.push_back(p4);
	L1.push_back(p5);
	L1.push_back(p6);
	L1.push_back(p7);
	L1.push_back(p8);

	for (std::list<person>::const_iterator it = L1.begin(); it != L1.end(); ++it)
	{
		std::cout << "姓名：" << it->m_Name << "年龄：" << (*it).m_Age
			<< "身高：" << it->m_Height << "体重：" << it->m_Weight << '\n';
	}

	std::cout << "-------------------------------" << '\n';

	L1.sort(mySort);
	for (std::list<person>::const_iterator it = L1.begin(); it != L1.end(); ++it)
	{
		std::cout << "姓名：" << it->m_Name << "年龄：" << (*it).m_Age
			<< "身高：" << it->m_Height << "体重：" << it->m_Weight << '\n';
	}

}

int main()
{
	test01();



	return 0;
}